
#include "Common/TableDataEx/TableExMgr.h"
#include "Common/TableDataEx/DeputyCfg.h"
#include "Common/TableDataEx/DuplicateCfg.h"
#include "Common/TableDataEx/ItemCfg.h"
#include "Common/TableDataEx/TeamCfg.h"
#include "Common/TableDataEx/AreaCfg.h"
#include "Common/TableDataEx/EquipCfg.h"
#include "Common/TableDataEx/UnionCfg.h"
#include "Common/TableDataEx/MapCfg.h"
#include "Common/TableDataEx/DropCfg.h"
#include "Common/TableDataEx/TeleportCfg.h"
#include "Common/TableDataEx/TitleCfg.h"
#include "Common/TableDataEx/PkModeCfg.h"
#include "Common/TableDataEx/ReduceCfg.h"
#include "Common/TableDataEx/ChatCfg.h"
#include "Common/TableDataEx/OperateCfg.h"
TableExMgr::TableExMgr()
{

}

TableExMgr::~TableExMgr()
{

}


bool TableExMgr::Init()
{
	bool result = false;
	//bool retCode = false;

	MMOLOG_PROCESS_ERROR(g_MakeDeputyCfgMgr());
	if (!g_GetDeputyCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeDuplicateCfgMgr());
	if (!g_GetDuplicateCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeItemCfgMgr());
	if (!g_GetItemCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeTeamCfgMgr());
	if (!g_GetTeamCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeAreaCfgMgr());
	if (!g_GetAreaCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeEquipCfgMgr());
	if (!g_GetEquipCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeUnionCfgMgr());
	if (!g_GetUnionCfgMgr()->Init())
	{
		goto Exit0;
	}
	MMOLOG_PROCESS_ERROR(g_MakeMapCfgMgr());
	if (!g_GetMapCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeDropCfgMgr());
	if (!g_GetDropCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeTeleportCfgMgr());
	if (!g_GetTeleportCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeTitleCfgMgr());
	if (!g_GetTitleCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakePkModeCfgMgr());
	if (!g_GetPkModeCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeReduceCfgMgr());
	if (!g_GetReduceCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeChatCfgMgr());
	if (!g_GetChatCfgMgr()->Init())
	{
		goto Exit0;
	}

	MMOLOG_PROCESS_ERROR(g_MakeOperateCfgMgr());
	if (!g_GetOperateCfgMgr()->Init())
	{
		goto Exit0;
	}

	result = true;
Exit0:
	if (!result)
	{
		UnInit();
	}

	return result;
}

bool TableExMgr::UnInit()
{
	if (g_GetDeputyCfgMgr())
	{
		g_GetDeputyCfgMgr()->UnInit();
		g_DelDeputyCfgMgr();
	}
	if (g_GetDuplicateCfgMgr())
	{
		g_GetDuplicateCfgMgr()->UnInit();
		g_DelDuplicateCfgMgr();
	}
	if (g_GetItemCfgMgr())
	{
		g_GetItemCfgMgr()->UnInit();
		g_DelItemCfgMgr();
	}
	if (g_GetTeamCfgMgr())
	{
		g_GetTeamCfgMgr()->UnInit();
		g_DelTeamCfgMgr();
	}

	if (g_GetAreaCfgMgr())
	{
		g_GetAreaCfgMgr()->UnInit();
		g_DelAreaCfgMgr();
	}

	if (g_GetEquipCfgMgr())
	{
		g_GetEquipCfgMgr()->UnInit();
		g_DelEquipCfgMgr();
	}

	if (g_GetUnionCfgMgr())
	{
		g_GetUnionCfgMgr()->UnInit();
		g_DelUnionCfgMgr();
	}

	if (g_GetMapCfgMgr())
	{
		g_GetMapCfgMgr()->UnInit();
		g_DelMapCfgMgr();
	}

	if (g_GetDropCfgMgr())
	{
		g_GetDropCfgMgr()->UnInit();
		g_DelDropCfgMgr();
	}

	if (g_GetTeleportCfgMgr())
	{
		g_GetTeleportCfgMgr()->UnInit();
		g_DelTeleportCfgMgr();
	}

	if (g_GetTitleCfgMgr())
	{
		g_GetTitleCfgMgr()->UnInit();
		g_DelTitleCfgMgr();
	}

	if (g_GetPkModeCfgMgr())
	{
		g_GetPkModeCfgMgr()->UnInit();
		g_DelPkModeCfgMgr();
	}

	if (g_GetReduceCfgMgr())
	{
		g_GetReduceCfgMgr()->UnInit();
		g_DelReduceCfgMgr();
	}

	if (g_GetChatCfgMgr())
	{
		g_GetChatCfgMgr()->UnInit();
		g_DelChatCfgMgr();
	}

	if (g_GetOperateCfgMgr())
	{
		g_GetOperateCfgMgr()->UnInit();
		g_DelOperateCfgMgr();
	}

	return true;
}

